<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>module Bundler::Thor::Actions - bundler: Ruby Standard Library Documentation</title>


<script src="../../js/navigation.js" defer></script>
<script src="../../js/search.js" defer></script>
<script src="../../js/search_index.js" defer></script>
<script src="../../js/searcher.js" defer></script>
<script src="../../js/darkfish.js" defer></script>

<script src="../../js/jquery-3.2.0.min.js"></script>

<script src="../../js/vue.min.js"></script>
<script src="../../js/js.cookie.min.js"></script>

<link href="../../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../../css/rdoc.css" rel="stylesheet">
<link href="../../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../../";
  var index_rel_prefix = "../../";
  var darkModeCsseHref = "../../css/rdoc-dm.css"
  var defaultModeCssHref = "../../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="module">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../../table_of_contents.html#pages">Pages</a>
    <a href="../../table_of_contents.html#classes">Classes</a>
    <a href="../../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
        
        
<div id="extends-section" class="nav-section">
  <h3>Extended With Modules</h3>

  <ul class="link-list">
    <li><a class="extend" href="Actions/ClassMethods.html">Bundler::Thor::Actions::ClassMethods</a>
  </ul>
</div>

        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li class="calls-super" ><a href="#method-c-new">::new</a>
    <li ><a href="#method-i-add_file">#add_file</a>
    <li ><a href="#method-i-add_link">#add_link</a>
    <li ><a href="#method-i-append_file">#append_file</a>
    <li ><a href="#method-i-append_to_file">#append_to_file</a>
    <li ><a href="#method-i-apply">#apply</a>
    <li ><a href="#method-i-capture">#capture</a>
    <li ><a href="#method-i-chmod">#chmod</a>
    <li ><a href="#method-i-comment_lines">#comment_lines</a>
    <li ><a href="#method-i-concat">#concat</a>
    <li ><a href="#method-i-copy_file">#copy_file</a>
    <li ><a href="#method-i-create_file">#create_file</a>
    <li ><a href="#method-i-create_link">#create_link</a>
    <li ><a href="#method-i-destination_root">#destination_root</a>
    <li ><a href="#method-i-destination_root-3D">#destination_root=</a>
    <li ><a href="#method-i-directory">#directory</a>
    <li ><a href="#method-i-empty_directory">#empty_directory</a>
    <li ><a href="#method-i-find_in_source_paths">#find_in_source_paths</a>
    <li ><a href="#method-i-get">#get</a>
    <li ><a href="#method-i-gsub_file">#gsub_file</a>
    <li ><a href="#method-i-in_root">#in_root</a>
    <li ><a href="#method-i-inject_into_class">#inject_into_class</a>
    <li ><a href="#method-i-inject_into_file">#inject_into_file</a>
    <li ><a href="#method-i-inject_into_module">#inject_into_module</a>
    <li ><a href="#method-i-insert_into_file">#insert_into_file</a>
    <li ><a href="#method-i-inside">#inside</a>
    <li ><a href="#method-i-link_file">#link_file</a>
    <li ><a href="#method-i-prepend_file">#prepend_file</a>
    <li ><a href="#method-i-prepend_to_file">#prepend_to_file</a>
    <li ><a href="#method-i-relative_to_original_destination_root">#relative_to_original_destination_root</a>
    <li ><a href="#method-i-remove_dir">#remove_dir</a>
    <li ><a href="#method-i-remove_file">#remove_file</a>
    <li ><a href="#method-i-run">#run</a>
    <li ><a href="#method-i-run_ruby_script">#run_ruby_script</a>
    <li ><a href="#method-i-source_paths">#source_paths</a>
    <li ><a href="#method-i-template">#template</a>
    <li ><a href="#method-i-thor">#thor</a>
    <li ><a href="#method-i-uncomment_lines">#uncomment_lines</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="module-Bundler::Thor::Actions">
    <h1 id="module-Bundler::Thor::Actions" class="module">
      module Bundler::Thor::Actions
    </h1>

    <section class="description">
    
    </section>

      <section id="5Buntitled-5D" class="documentation-section">


      <section class="constants-list">
      <header>
      <h3>Constants</h3>
      </header>
      <dl>
          <dt id="WARNINGS">WARNINGS
          <dd><p>Injects the given content into a file. Different from <a href="Actions.html#method-i-gsub_file"><code>gsub_file</code></a>, this method is reversible.</p>

<h4 id="label-Parameters">Parameters<span><a href="#label-Parameters">&para;</a> <a href="#top">&uarr;</a></span></h4>
<dl class="rdoc-list note-list"><dt>destination&lt;String&gt;
<dd>
<p>Relative path to the destination root</p>
</dd><dt>data&lt;String&gt;
<dd>
<p>Data to add to the file. Can be given as a block.</p>
</dd><dt>config&lt;Hash&gt;
<dd>
<p>give :verbose =&gt; false to not log the status and the flag for injection (:after or :before) or :force =&gt; true for insert two or more times the same content.</p>
</dd></dl>

<h4 id="label-Examples">Examples<span><a href="#label-Examples">&para;</a> <a href="#top">&uarr;</a></span></h4>

<pre class="ruby"><span class="ruby-identifier">insert_into_file</span> <span class="ruby-string">&quot;config/environment.rb&quot;</span>, <span class="ruby-string">&quot;config.gem :thor&quot;</span>, <span class="ruby-value">:after</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;Rails::Initializer.run do |config|\n&quot;</span>

<span class="ruby-identifier">insert_into_file</span> <span class="ruby-string">&quot;config/environment.rb&quot;</span>, <span class="ruby-value">:after</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;Rails::Initializer.run do |config|\n&quot;</span> <span class="ruby-keyword">do</span>
  <span class="ruby-identifier">gems</span> = <span class="ruby-identifier">ask</span> <span class="ruby-string">&quot;Which gems would you like to add?&quot;</span>
  <span class="ruby-identifier">gems</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">&quot; &quot;</span>).<span class="ruby-identifier">map</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">gem</span><span class="ruby-operator">|</span> <span class="ruby-node">&quot;  config.gem :#{gem}&quot;</span> }.<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;\n&quot;</span>)
<span class="ruby-keyword">end</span>
</pre>
        </dl>
        </section>

        <section class="attribute-method-details" class="method-section">
        <header>
        <h3>Attributes</h3>
        </header>

          <div id="attribute-i-behavior" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">behavior</span><span
                class="attribute-access-type">[RW]</span>
            </div>

            <div class="method-description">
              
              </div>
            </div>
          <div id="attribute-i-output_buffer" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">output_buffer</span><span
                class="attribute-access-type">[RW]</span>
            </div>

            <div class="method-description">
              
              </div>
            </div>
            </section>


                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-new" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">new</span><span
                                class="method-args">(args = [], options = {}, config = {})</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Extends initializer to add more configuration options.</p>

<h4 id="method-c-new-label-Configuration">Configuration<span><a href="#method-c-new-label-Configuration">&para;</a> <a href="#top">&uarr;</a></span></h4>
<dl class="rdoc-list note-list"><dt>behavior&lt;Symbol&gt;
<dd>
<p>The actions default behavior. Can be :invoke or :revoke. It also accepts :force, :skip and :pretend to set the behavior and the respective option.</p>
</dd><dt><a href="Actions.html#method-i-destination_root"><code>destination_root</code></a>&lt;String&gt;
<dd>
<p>The root directory needed for some actions.</p>
</dd></dl>
                                <div class="method-calls-super">
                                  Calls superclass method
                                  
                              </div>

                              <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File bundler/vendor/thor/lib/thor/actions.rb, line 72</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">args</span> = [], <span class="ruby-identifier">options</span> = {}, <span class="ruby-identifier">config</span> = {})
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">behavior</span> = <span class="ruby-keyword">case</span> <span class="ruby-identifier">config</span>[<span class="ruby-value">:behavior</span>].<span class="ruby-identifier">to_s</span>
  <span class="ruby-keyword">when</span> <span class="ruby-string">&quot;force&quot;</span>, <span class="ruby-string">&quot;skip&quot;</span>
    <span class="ruby-identifier">_cleanup_options_and_set</span>(<span class="ruby-identifier">options</span>, <span class="ruby-identifier">config</span>[<span class="ruby-value">:behavior</span>])
    <span class="ruby-value">:invoke</span>
  <span class="ruby-keyword">when</span> <span class="ruby-string">&quot;revoke&quot;</span>
    <span class="ruby-value">:revoke</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-value">:invoke</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">super</span>
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">destination_root</span> = <span class="ruby-identifier">config</span>[<span class="ruby-value">:destination_root</span>]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-add_file" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">add_file</span><span
                                class="method-args">(destination, *args, &amp;block)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Actions.html#method-i-create_file">create_file</a>
                            </div>
                          </div>

                  <div id="method-i-add_link" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">add_link</span><span
                                class="method-args">(destination, *args)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Actions.html#method-i-create_link">create_link</a>
                            </div>
                          </div>

                  <div id="method-i-append_file" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">append_file</span><span
                                class="method-args">(path, *args, &amp;block)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Actions.html#method-i-append_to_file">append_to_file</a>
                            </div>
                          </div>

                  <div id="method-i-append_to_file" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">append_to_file</span><span
                                class="method-args">(path, *args, &amp;block)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Append text to a file. Since it depends on <a href="Actions.html#method-i-insert_into_file"><code>insert_into_file</code></a>, it’s reversible.</p>

<h4 id="method-i-append_to_file-label-Parameters">Parameters<span><a href="#method-i-append_to_file-label-Parameters">&para;</a> <a href="#top">&uarr;</a></span></h4>
<dl class="rdoc-list note-list"><dt>path&lt;String&gt;
<dd>
<p>path of the file to be changed</p>
</dd><dt>data&lt;String&gt;
<dd>
<p>the data to append to the file, can be also given as a block.</p>
</dd><dt>config&lt;Hash&gt;
<dd>
<p>give :verbose =&gt; false to not log the status.</p>
</dd></dl>

<h4 id="method-i-append_to_file-label-Example">Example<span><a href="#method-i-append_to_file-label-Example">&para;</a> <a href="#top">&uarr;</a></span></h4>

<pre class="ruby"><span class="ruby-identifier">append_to_file</span> <span class="ruby-string">&#39;config/environments/test.rb&#39;</span>, <span class="ruby-string">&#39;config.gem &quot;rspec&quot;&#39;</span>

<span class="ruby-identifier">append_to_file</span> <span class="ruby-string">&#39;config/environments/test.rb&#39;</span> <span class="ruby-keyword">do</span>
  <span class="ruby-string">&#39;config.gem &quot;rspec&quot;&#39;</span>
<span class="ruby-keyword">end</span>
</pre>

                              <div class="method-source-code" id="append_to_file-source">
            <pre><span class="ruby-comment"># File bundler/vendor/thor/lib/thor/actions/file_manipulation.rb, line 195</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">append_to_file</span>(<span class="ruby-identifier">path</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">config</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">pop</span> <span class="ruby-operator">:</span> {}
  <span class="ruby-identifier">config</span>[<span class="ruby-value">:before</span>] = <span class="ruby-regexp">/\z/</span>
  <span class="ruby-identifier">insert_into_file</span>(<span class="ruby-identifier">path</span>, <span class="ruby-operator">*</span>(<span class="ruby-identifier">args</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">config</span>), <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Actions.html#method-i-append_file">append_file</a>
                            </div>

                          </div>

                  <div id="method-i-apply" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">apply</span><span
                                class="method-args">(path, config = {})</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Loads an external file and execute it in the instance binding.</p>

<h4 id="method-i-apply-label-Parameters">Parameters<span><a href="#method-i-apply-label-Parameters">&para;</a> <a href="#top">&uarr;</a></span></h4>
<dl class="rdoc-list note-list"><dt>path&lt;String&gt;
<dd>
<p>The path to the file to execute. Can be a web address or a relative path from the source root.</p>
</dd></dl>

<h4 id="method-i-apply-label-Examples">Examples<span><a href="#method-i-apply-label-Examples">&para;</a> <a href="#top">&uarr;</a></span></h4>

<pre class="ruby"><span class="ruby-identifier">apply</span> <span class="ruby-string">&quot;http://gist.github.com/103208&quot;</span>

<span class="ruby-identifier">apply</span> <span class="ruby-string">&quot;recipes/jquery.rb&quot;</span>
</pre>

                              <div class="method-source-code" id="apply-source">
            <pre><span class="ruby-comment"># File bundler/vendor/thor/lib/thor/actions.rb, line 216</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">apply</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">config</span> = {})
  <span class="ruby-identifier">verbose</span> = <span class="ruby-identifier">config</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-value">:verbose</span>, <span class="ruby-keyword">true</span>)
  <span class="ruby-identifier">is_uri</span>  = <span class="ruby-identifier">path</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">%r{^https?\://}</span>
  <span class="ruby-identifier">path</span>    = <span class="ruby-identifier">find_in_source_paths</span>(<span class="ruby-identifier">path</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">is_uri</span>

  <span class="ruby-identifier">say_status</span> <span class="ruby-value">:apply</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">verbose</span>
  <span class="ruby-identifier">shell</span>.<span class="ruby-identifier">padding</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>

  <span class="ruby-identifier">contents</span> = <span class="ruby-keyword">if</span> <span class="ruby-identifier">is_uri</span>
    <span class="ruby-identifier">require</span> <span class="ruby-string">&quot;open-uri&quot;</span>
    <span class="ruby-comment"># for ruby 2.1-2.4</span>
    <span class="ruby-constant">URI</span>.<span class="ruby-identifier">send</span>(<span class="ruby-value">:open</span>, <span class="ruby-identifier">path</span>, <span class="ruby-string">&quot;Accept&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;application/x-thor-template&quot;</span>, <span class="ruby-operator">&amp;</span><span class="ruby-value">:read</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">path</span>, <span class="ruby-operator">&amp;</span><span class="ruby-value">:read</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">instance_eval</span>(<span class="ruby-identifier">contents</span>, <span class="ruby-identifier">path</span>)
  <span class="ruby-identifier">shell</span>.<span class="ruby-identifier">padding</span> <span class="ruby-operator">-=</span> <span class="ruby-value">1</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-chmod" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">chmod</span><span
                                class="method-args">(path, mode, config = {})</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Changes the mode of the given file or directory.</p>

<h4 id="method-i-chmod-label-Parameters">Parameters<span><a href="#method-i-chmod-label-Parameters">&para;</a> <a href="#top">&uarr;</a></span></h4>
<dl class="rdoc-list note-list"><dt>mode&lt;Integer&gt;
<dd>
<p>the file mode</p>
</dd><dt>path&lt;String&gt;
<dd>
<p>the name of the file to change mode</p>
</dd><dt>config&lt;Hash&gt;
<dd>
<p>give :verbose =&gt; false to not log the status.</p>
</dd></dl>

<h4 id="method-i-chmod-label-Example">Example<span><a href="#method-i-chmod-label-Example">&para;</a> <a href="#top">&uarr;</a></span></h4>

<pre class="ruby"><span class="ruby-identifier">chmod</span> <span class="ruby-string">&quot;script/server&quot;</span>, <span class="ruby-value">0755</span>
</pre>

                              <div class="method-source-code" id="chmod-source">
            <pre><span class="ruby-comment"># File bundler/vendor/thor/lib/thor/actions/file_manipulation.rb, line 148</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">chmod</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">mode</span>, <span class="ruby-identifier">config</span> = {})
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">behavior</span> <span class="ruby-operator">==</span> <span class="ruby-value">:invoke</span>
  <span class="ruby-identifier">path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">destination_root</span>)
  <span class="ruby-identifier">say_status</span> <span class="ruby-value">:chmod</span>, <span class="ruby-identifier">relative_to_original_destination_root</span>(<span class="ruby-identifier">path</span>), <span class="ruby-identifier">config</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-value">:verbose</span>, <span class="ruby-keyword">true</span>)
  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:pretend</span>]
    <span class="ruby-identifier">require</span> <span class="ruby-string">&quot;fileutils&quot;</span>
    <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">chmod_R</span>(<span class="ruby-identifier">mode</span>, <span class="ruby-identifier">path</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-comment_lines" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">comment_lines</span><span
                                class="method-args">(path, flag, *args)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Comment all lines matching a given regex.  It will leave the space which existed before the beginning of the line in tact and will insert a single space after the comment hash.</p>

<h4 id="method-i-comment_lines-label-Parameters">Parameters<span><a href="#method-i-comment_lines-label-Parameters">&para;</a> <a href="#top">&uarr;</a></span></h4>
<dl class="rdoc-list note-list"><dt>path&lt;String&gt;
<dd>
<p>path of the file to be changed</p>
</dd><dt>flag&lt;Regexp|String&gt;
<dd>
<p>the regexp or string used to decide which lines to comment</p>
</dd><dt>config&lt;Hash&gt;
<dd>
<p>give :verbose =&gt; false to not log the status.</p>
</dd></dl>

<h4 id="method-i-comment_lines-label-Example">Example<span><a href="#method-i-comment_lines-label-Example">&para;</a> <a href="#top">&uarr;</a></span></h4>

<pre class="ruby"><span class="ruby-identifier">comment_lines</span> <span class="ruby-string">&#39;config/initializers/session_store.rb&#39;</span>, <span class="ruby-regexp">/cookie_store/</span>
</pre>

                              <div class="method-source-code" id="comment_lines-source">
            <pre><span class="ruby-comment"># File bundler/vendor/thor/lib/thor/actions/file_manipulation.rb, line 312</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">comment_lines</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">flag</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
  <span class="ruby-identifier">flag</span> = <span class="ruby-identifier">flag</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:source</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">flag</span>.<span class="ruby-identifier">source</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">flag</span>

  <span class="ruby-identifier">gsub_file</span>(<span class="ruby-identifier">path</span>, <span class="ruby-regexp">/^(\s*)([^#\n]*#{flag})/</span>, <span class="ruby-string">&#39;\1# \2&#39;</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-copy_file" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">copy_file</span><span
                                class="method-args">(source, *args) { |content| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <h4 id="method-i-copy_file-label-Examples">Examples<span><a href="#method-i-copy_file-label-Examples">&para;</a> <a href="#top">&uarr;</a></span></h4>

<pre class="ruby"><span class="ruby-identifier">copy_file</span> <span class="ruby-string">&quot;README&quot;</span>, <span class="ruby-string">&quot;doc/README&quot;</span>

<span class="ruby-identifier">copy_file</span> <span class="ruby-string">&quot;doc/README&quot;</span>
</pre>

                              <div class="method-source-code" id="copy_file-source">
            <pre><span class="ruby-comment"># File bundler/vendor/thor/lib/thor/actions/file_manipulation.rb, line 21</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">copy_file</span>(<span class="ruby-identifier">source</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">config</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">pop</span> <span class="ruby-operator">:</span> {}
  <span class="ruby-identifier">destination</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">first</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">source</span>
  <span class="ruby-identifier">source</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">find_in_source_paths</span>(<span class="ruby-identifier">source</span>.<span class="ruby-identifier">to_s</span>))

  <span class="ruby-identifier">resulting_destination</span> = <span class="ruby-identifier">create_file</span> <span class="ruby-identifier">destination</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">config</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">content</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">binread</span>(<span class="ruby-identifier">source</span>)
    <span class="ruby-identifier">content</span> = <span class="ruby-keyword">yield</span>(<span class="ruby-identifier">content</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">block</span>
    <span class="ruby-identifier">content</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">config</span>[<span class="ruby-value">:mode</span>] <span class="ruby-operator">==</span> <span class="ruby-value">:preserve</span>
    <span class="ruby-identifier">mode</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-identifier">source</span>).<span class="ruby-identifier">mode</span>
    <span class="ruby-identifier">chmod</span>(<span class="ruby-identifier">resulting_destination</span>, <span class="ruby-identifier">mode</span>, <span class="ruby-identifier">config</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-create_file" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">create_file</span><span
                                class="method-args">(destination, *args, &amp;block)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Create a new file relative to the destination root with the given data, which is the return value of a block or a data string.</p>

<h4 id="method-i-create_file-label-Parameters">Parameters<span><a href="#method-i-create_file-label-Parameters">&para;</a> <a href="#top">&uarr;</a></span></h4>
<dl class="rdoc-list note-list"><dt>destination&lt;String&gt;
<dd>
<p>the relative path to the destination root.</p>
</dd><dt>data&lt;String|NilClass&gt;
<dd>
<p>the data to append to the file.</p>
</dd><dt>config&lt;Hash&gt;
<dd>
<p>give :verbose =&gt; false to not log the status.</p>
</dd></dl>

<h4 id="method-i-create_file-label-Examples">Examples<span><a href="#method-i-create_file-label-Examples">&para;</a> <a href="#top">&uarr;</a></span></h4>

<pre class="ruby"><span class="ruby-identifier">create_file</span> <span class="ruby-string">&quot;lib/fun_party.rb&quot;</span> <span class="ruby-keyword">do</span>
  <span class="ruby-identifier">hostname</span> = <span class="ruby-identifier">ask</span>(<span class="ruby-string">&quot;What is the virtual hostname I should use?&quot;</span>)
  <span class="ruby-node">&quot;vhost.name = #{hostname}&quot;</span>
<span class="ruby-keyword">end</span>

<span class="ruby-identifier">create_file</span> <span class="ruby-string">&quot;config/apache.conf&quot;</span>, <span class="ruby-string">&quot;your apache config&quot;</span>
</pre>

                              <div class="method-source-code" id="create_file-source">
            <pre><span class="ruby-comment"># File bundler/vendor/thor/lib/thor/actions/create_file.rb, line 22</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">create_file</span>(<span class="ruby-identifier">destination</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">config</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">pop</span> <span class="ruby-operator">:</span> {}
  <span class="ruby-identifier">data</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">first</span>
  <span class="ruby-identifier">action</span> <span class="ruby-constant">CreateFile</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword">self</span>, <span class="ruby-identifier">destination</span>, <span class="ruby-identifier">block</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">config</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Actions.html#method-i-add_file">add_file</a>
                            </div>

                          </div>

                  <div id="method-i-create_link" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">create_link</span><span
                                class="method-args">(destination, *args)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Create a new file relative to the destination root from the given source.</p>

<h4 id="method-i-create_link-label-Parameters">Parameters<span><a href="#method-i-create_link-label-Parameters">&para;</a> <a href="#top">&uarr;</a></span></h4>
<dl class="rdoc-list note-list"><dt>destination&lt;String&gt;
<dd>
<p>the relative path to the destination root.</p>
</dd><dt>source&lt;String|NilClass&gt;
<dd>
<p>the relative path to the source root.</p>
</dd><dt>config&lt;Hash&gt;
<dd>
<p>give :verbose =&gt; false to not log the status.</p>
</dd><dt>
<dd>
<p>give :symbolic =&gt; false for hard link.</p>
</dd></dl>

<h4 id="method-i-create_link-label-Examples">Examples<span><a href="#method-i-create_link-label-Examples">&para;</a> <a href="#top">&uarr;</a></span></h4>

<pre class="ruby"><span class="ruby-identifier">create_link</span> <span class="ruby-string">&quot;config/apache.conf&quot;</span>, <span class="ruby-string">&quot;/etc/apache.conf&quot;</span>
</pre>

                              <div class="method-source-code" id="create_link-source">
            <pre><span class="ruby-comment"># File bundler/vendor/thor/lib/thor/actions/create_link.rb, line 17</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">create_link</span>(<span class="ruby-identifier">destination</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
  <span class="ruby-identifier">config</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">pop</span> <span class="ruby-operator">:</span> {}
  <span class="ruby-identifier">source</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">first</span>
  <span class="ruby-identifier">action</span> <span class="ruby-constant">CreateLink</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword">self</span>, <span class="ruby-identifier">destination</span>, <span class="ruby-identifier">source</span>, <span class="ruby-identifier">config</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Actions.html#method-i-add_link">add_link</a>
                            </div>

                          </div>

                  <div id="method-i-destination_root" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">destination_root</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the root for this thor class (also aliased as destination root).</p>

                              <div class="method-source-code" id="destination_root-source">
            <pre><span class="ruby-comment"># File bundler/vendor/thor/lib/thor/actions.rb, line 99</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">destination_root</span>
  <span class="ruby-ivar">@destination_stack</span>.<span class="ruby-identifier">last</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-destination_root-3D" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">destination_root=</span><span
                                class="method-args">(root)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sets the root for this thor class. Relatives path are added to the directory where the script was invoked and expanded.</p>

                              <div class="method-source-code" id="destination_root-3D-source">
            <pre><span class="ruby-comment"># File bundler/vendor/thor/lib/thor/actions.rb, line 106</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">destination_root=</span>(<span class="ruby-identifier">root</span>)
  <span class="ruby-ivar">@destination_stack</span> <span class="ruby-operator">||=</span> []
  <span class="ruby-ivar">@destination_stack</span>[<span class="ruby-value">0</span>] = <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">root</span> <span class="ruby-operator">||</span> <span class="ruby-string">&quot;&quot;</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-directory" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">directory</span><span
                                class="method-args">(source, *args, &amp;block)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Copies recursively the files from source directory to root directory. If any of the files finishes with .tt, it’s considered to be a template and is placed in the destination without the extension .tt. If any empty directory is found, it’s copied and all .empty_directory files are ignored. If any file name is wrapped within % signs, the text within the % signs will be executed as a method and replaced with the returned value. Let’s suppose a doc directory with the following files:</p>

<pre>doc/
  components/.empty_directory
  README
  rdoc.rb.tt
  %app_name%.rb</pre>

<p>When invoked as:</p>

<pre class="ruby"><span class="ruby-identifier">directory</span> <span class="ruby-string">&quot;doc&quot;</span>
</pre>

<p>It will create a doc directory in the destination with the following files (assuming that the ‘app_name` method returns the value “blog”):</p>

<pre class="ruby"><span class="ruby-identifier">doc</span><span class="ruby-operator">/</span>
  <span class="ruby-identifier">components</span><span class="ruby-operator">/</span>
  <span class="ruby-constant">README</span>
  <span class="ruby-identifier">rdoc</span>.<span class="ruby-identifier">rb</span>
  <span class="ruby-identifier">blog</span>.<span class="ruby-identifier">rb</span>
</pre>

<p><strong>Encoded path note:</strong> Since Bundler::Thor internals use Object#respond_to? to check if it can expand %something%, this ‘something` should be a public method in the class calling <a href="Actions.html#method-i-directory"><code>directory</code></a>. If a method is private, Bundler::Thor stack raises PrivateMethodEncodedError.</p>

<h4 id="method-i-directory-label-Parameters">Parameters<span><a href="#method-i-directory-label-Parameters">&para;</a> <a href="#top">&uarr;</a></span></h4>
<dl class="rdoc-list note-list"><dt>source&lt;String&gt;
<dd>
<p>the relative path to the source root.</p>
</dd><dt>destination&lt;String&gt;
<dd>
<p>the relative path to the destination root.</p>
</dd><dt>config&lt;Hash&gt;
<dd>
<p>give :verbose =&gt; false to not log the status. If :recursive =&gt; false, does not look for paths recursively. If :mode =&gt; :preserve, preserve the file mode from the source. If :exclude_pattern =&gt; /regexp/, prevents copying files that match that regexp.</p>
</dd></dl>

<h4 id="method-i-directory-label-Examples">Examples<span><a href="#method-i-directory-label-Examples">&para;</a> <a href="#top">&uarr;</a></span></h4>

<pre class="ruby"><span class="ruby-identifier">directory</span> <span class="ruby-string">&quot;doc&quot;</span>
<span class="ruby-identifier">directory</span> <span class="ruby-string">&quot;doc&quot;</span>, <span class="ruby-string">&quot;docs&quot;</span>, <span class="ruby-value">:recursive</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-keyword">false</span>
</pre>

                              <div class="method-source-code" id="directory-source">
            <pre><span class="ruby-comment"># File bundler/vendor/thor/lib/thor/actions/directory.rb, line 49</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">directory</span>(<span class="ruby-identifier">source</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">config</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">pop</span> <span class="ruby-operator">:</span> {}
  <span class="ruby-identifier">destination</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">first</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">source</span>
  <span class="ruby-identifier">action</span> <span class="ruby-constant">Directory</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword">self</span>, <span class="ruby-identifier">source</span>, <span class="ruby-identifier">destination</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">source</span>, <span class="ruby-identifier">config</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-empty_directory" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">empty_directory</span><span
                                class="method-args">(destination, config = {})</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates an empty directory.</p>

<h4 id="method-i-empty_directory-label-Parameters">Parameters<span><a href="#method-i-empty_directory-label-Parameters">&para;</a> <a href="#top">&uarr;</a></span></h4>
<dl class="rdoc-list note-list"><dt>destination&lt;String&gt;
<dd>
<p>the relative path to the destination root.</p>
</dd><dt>config&lt;Hash&gt;
<dd>
<p>give :verbose =&gt; false to not log the status.</p>
</dd></dl>

<h4 id="method-i-empty_directory-label-Examples">Examples<span><a href="#method-i-empty_directory-label-Examples">&para;</a> <a href="#top">&uarr;</a></span></h4>

<pre class="ruby"><span class="ruby-identifier">empty_directory</span> <span class="ruby-string">&quot;doc&quot;</span>
</pre>

                              <div class="method-source-code" id="empty_directory-source">
            <pre><span class="ruby-comment"># File bundler/vendor/thor/lib/thor/actions/empty_directory.rb, line 13</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">empty_directory</span>(<span class="ruby-identifier">destination</span>, <span class="ruby-identifier">config</span> = {})
  <span class="ruby-identifier">action</span> <span class="ruby-constant">EmptyDirectory</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword">self</span>, <span class="ruby-identifier">destination</span>, <span class="ruby-identifier">config</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-find_in_source_paths" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">find_in_source_paths</span><span
                                class="method-args">(file)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Receives a file or directory and search for it in the source paths.</p>

                              <div class="method-source-code" id="find_in_source_paths-source">
            <pre><span class="ruby-comment"># File bundler/vendor/thor/lib/thor/actions.rb, line 133</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">find_in_source_paths</span>(<span class="ruby-identifier">file</span>)
  <span class="ruby-identifier">possible_files</span> = [<span class="ruby-identifier">file</span>, <span class="ruby-identifier">file</span> <span class="ruby-operator">+</span> <span class="ruby-constant">TEMPLATE_EXTNAME</span>]
  <span class="ruby-identifier">relative_root</span> = <span class="ruby-identifier">relative_to_original_destination_root</span>(<span class="ruby-identifier">destination_root</span>, <span class="ruby-keyword">false</span>)

  <span class="ruby-identifier">source_paths</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">source</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">possible_files</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">source_file</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">f</span>, <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">source</span>, <span class="ruby-identifier">relative_root</span>))
      <span class="ruby-keyword">return</span> <span class="ruby-identifier">source_file</span> <span class="ruby-keyword">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">source_file</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">message</span> = <span class="ruby-node">&quot;Could not find #{file.inspect} in any of your source paths. &quot;</span>.<span class="ruby-identifier">dup</span>

  <span class="ruby-keyword">unless</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">source_root</span>
    <span class="ruby-identifier">message</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;Please invoke #{self.class.name}.source_root(PATH) with the PATH containing your templates. &quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">message</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">source_paths</span>.<span class="ruby-identifier">empty?</span>
               <span class="ruby-string">&quot;Currently you have no source paths.&quot;</span>
             <span class="ruby-keyword">else</span>
               <span class="ruby-node">&quot;Your current source paths are: \n#{source_paths.join(&quot;\n&quot;)}&quot;</span>
             <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">raise</span> <span class="ruby-constant">Error</span>, <span class="ruby-identifier">message</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-get" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">get</span><span
                                class="method-args">(source, *args) { |render| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Gets the content at the given address and places it at the given relative destination. If a block is given instead of destination, the content of the url is yielded and used as location.</p>

<p><code>get</code> relies on open-uri, so passing application user input would provide a command injection attack vector.</p>

<h4 id="method-i-get-label-Parameters">Parameters<span><a href="#method-i-get-label-Parameters">&para;</a> <a href="#top">&uarr;</a></span></h4>
<dl class="rdoc-list note-list"><dt>source&lt;String&gt;
<dd>
<p>the address of the given content.</p>
</dd><dt>destination&lt;String&gt;
<dd>
<p>the relative path to the destination root.</p>
</dd><dt>config&lt;Hash&gt;
<dd>
<p>give :verbose =&gt; false to not log the status.</p>
</dd></dl>

<h4 id="method-i-get-label-Examples">Examples<span><a href="#method-i-get-label-Examples">&para;</a> <a href="#top">&uarr;</a></span></h4>

<pre class="ruby"><span class="ruby-identifier">get</span> <span class="ruby-string">&quot;http://gist.github.com/103208&quot;</span>, <span class="ruby-string">&quot;doc/README&quot;</span>

<span class="ruby-identifier">get</span> <span class="ruby-string">&quot;http://gist.github.com/103208&quot;</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">content</span><span class="ruby-operator">|</span>
  <span class="ruby-identifier">content</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">&quot;\n&quot;</span>).<span class="ruby-identifier">first</span>
<span class="ruby-keyword">end</span>
</pre>

                              <div class="method-source-code" id="get-source">
            <pre><span class="ruby-comment"># File bundler/vendor/thor/lib/thor/actions/file_manipulation.rb, line 79</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">get</span>(<span class="ruby-identifier">source</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">config</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">pop</span> <span class="ruby-operator">:</span> {}
  <span class="ruby-identifier">destination</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">first</span>

  <span class="ruby-identifier">render</span> = <span class="ruby-keyword">if</span> <span class="ruby-identifier">source</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">%r{^https?\://}</span>
    <span class="ruby-identifier">require</span> <span class="ruby-string">&quot;open-uri&quot;</span>
    <span class="ruby-constant">URI</span>.<span class="ruby-identifier">send</span>(<span class="ruby-value">:open</span>, <span class="ruby-identifier">source</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">input</span><span class="ruby-operator">|</span> <span class="ruby-identifier">input</span>.<span class="ruby-identifier">binmode</span>.<span class="ruby-identifier">read</span> }
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">source</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">find_in_source_paths</span>(<span class="ruby-identifier">source</span>.<span class="ruby-identifier">to_s</span>))
    <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">source</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">input</span><span class="ruby-operator">|</span> <span class="ruby-identifier">input</span>.<span class="ruby-identifier">binmode</span>.<span class="ruby-identifier">read</span> }
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">destination</span> <span class="ruby-operator">||=</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">block_given?</span>
    <span class="ruby-identifier">block</span>.<span class="ruby-identifier">arity</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span> <span class="ruby-operator">?</span> <span class="ruby-keyword">yield</span>(<span class="ruby-identifier">render</span>) <span class="ruby-operator">:</span> <span class="ruby-keyword">yield</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span>(<span class="ruby-identifier">source</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">create_file</span> <span class="ruby-identifier">destination</span>, <span class="ruby-identifier">render</span>, <span class="ruby-identifier">config</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-gsub_file" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">gsub_file</span><span
                                class="method-args">(path, flag, *args, &amp;block)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Run a regular expression replacement on a file.</p>

<h4 id="method-i-gsub_file-label-Parameters">Parameters<span><a href="#method-i-gsub_file-label-Parameters">&para;</a> <a href="#top">&uarr;</a></span></h4>
<dl class="rdoc-list note-list"><dt>path&lt;String&gt;
<dd>
<p>path of the file to be changed</p>
</dd><dt>flag&lt;Regexp|String&gt;
<dd>
<p>the regexp or string to be replaced</p>
</dd><dt>replacement&lt;String&gt;
<dd>
<p>the replacement, can be also given as a block</p>
</dd><dt>config&lt;Hash&gt;
<dd>
<p>give :verbose =&gt; false to not log the status, and :force =&gt; true, to force the replacement regardless of runner behavior.</p>
</dd></dl>

<h4 id="method-i-gsub_file-label-Example">Example<span><a href="#method-i-gsub_file-label-Example">&para;</a> <a href="#top">&uarr;</a></span></h4>

<pre class="ruby"><span class="ruby-identifier">gsub_file</span> <span class="ruby-string">&#39;app/controllers/application_controller.rb&#39;</span>, <span class="ruby-regexp">/#\s*(filter_parameter_logging :password)/</span>, <span class="ruby-string">&#39;\1&#39;</span>

<span class="ruby-identifier">gsub_file</span> <span class="ruby-string">&#39;README&#39;</span>, <span class="ruby-regexp">/rake/</span>, <span class="ruby-value">:green</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">match</span><span class="ruby-operator">|</span>
  <span class="ruby-identifier">match</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot; no more. Use thor!&quot;</span>
<span class="ruby-keyword">end</span>
</pre>

                              <div class="method-source-code" id="gsub_file-source">
            <pre><span class="ruby-comment"># File bundler/vendor/thor/lib/thor/actions/file_manipulation.rb, line 265</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">gsub_file</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">flag</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">config</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">pop</span> <span class="ruby-operator">:</span> {}

  <span class="ruby-keyword">return</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">behavior</span> <span class="ruby-operator">==</span> <span class="ruby-value">:invoke</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">config</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-value">:force</span>, <span class="ruby-keyword">false</span>)

  <span class="ruby-identifier">path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">destination_root</span>)
  <span class="ruby-identifier">say_status</span> <span class="ruby-value">:gsub</span>, <span class="ruby-identifier">relative_to_original_destination_root</span>(<span class="ruby-identifier">path</span>), <span class="ruby-identifier">config</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-value">:verbose</span>, <span class="ruby-keyword">true</span>)

  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:pretend</span>]
    <span class="ruby-identifier">content</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">binread</span>(<span class="ruby-identifier">path</span>)
    <span class="ruby-identifier">content</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-identifier">flag</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
    <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">path</span>, <span class="ruby-string">&quot;wb&quot;</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span> <span class="ruby-identifier">file</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">content</span>) }
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-in_root" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">in_root</span><span
                                class="method-args">() { || ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Goes to the root and execute the given block.</p>

                              <div class="method-source-code" id="in_root-source">
            <pre><span class="ruby-comment"># File bundler/vendor/thor/lib/thor/actions.rb, line 200</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">in_root</span>
  <span class="ruby-identifier">inside</span>(<span class="ruby-ivar">@destination_stack</span>.<span class="ruby-identifier">first</span>) { <span class="ruby-keyword">yield</span> }
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-inject_into_class" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">inject_into_class</span><span
                                class="method-args">(path, klass, *args, &amp;block)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Injects text right after the class definition. Since it depends on <a href="Actions.html#method-i-insert_into_file"><code>insert_into_file</code></a>, it’s reversible.</p>

<h4 id="method-i-inject_into_class-label-Parameters">Parameters<span><a href="#method-i-inject_into_class-label-Parameters">&para;</a> <a href="#top">&uarr;</a></span></h4>
<dl class="rdoc-list note-list"><dt>path&lt;String&gt;
<dd>
<p>path of the file to be changed</p>
</dd><dt>klass&lt;String|Class&gt;
<dd>
<p>the class to be manipulated</p>
</dd><dt>data&lt;String&gt;
<dd>
<p>the data to append to the class, can be also given as a block.</p>
</dd><dt>config&lt;Hash&gt;
<dd>
<p>give :verbose =&gt; false to not log the status.</p>
</dd></dl>

<h4 id="method-i-inject_into_class-label-Examples">Examples<span><a href="#method-i-inject_into_class-label-Examples">&para;</a> <a href="#top">&uarr;</a></span></h4>

<pre class="ruby"><span class="ruby-identifier">inject_into_class</span> <span class="ruby-string">&quot;app/controllers/application_controller.rb&quot;</span>, <span class="ruby-string">&quot;ApplicationController&quot;</span>, <span class="ruby-string">&quot;  filter_parameter :password\n&quot;</span>

<span class="ruby-identifier">inject_into_class</span> <span class="ruby-string">&quot;app/controllers/application_controller.rb&quot;</span>, <span class="ruby-string">&quot;ApplicationController&quot;</span> <span class="ruby-keyword">do</span>
  <span class="ruby-string">&quot;  filter_parameter :password\n&quot;</span>
<span class="ruby-keyword">end</span>
</pre>

                              <div class="method-source-code" id="inject_into_class-source">
            <pre><span class="ruby-comment"># File bundler/vendor/thor/lib/thor/actions/file_manipulation.rb, line 219</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">inject_into_class</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">klass</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">config</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">pop</span> <span class="ruby-operator">:</span> {}
  <span class="ruby-identifier">config</span>[<span class="ruby-value">:after</span>] = <span class="ruby-regexp">/class #{klass}\n|class #{klass} .*\n/</span>
  <span class="ruby-identifier">insert_into_file</span>(<span class="ruby-identifier">path</span>, <span class="ruby-operator">*</span>(<span class="ruby-identifier">args</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">config</span>), <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-inject_into_file" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">inject_into_file</span><span
                                class="method-args">(destination, *args, &amp;block)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Actions.html#method-i-insert_into_file">insert_into_file</a>
                            </div>
                          </div>

                  <div id="method-i-inject_into_module" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">inject_into_module</span><span
                                class="method-args">(path, module_name, *args, &amp;block)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Injects text right after the module definition. Since it depends on <a href="Actions.html#method-i-insert_into_file"><code>insert_into_file</code></a>, it’s reversible.</p>

<h4 id="method-i-inject_into_module-label-Parameters">Parameters<span><a href="#method-i-inject_into_module-label-Parameters">&para;</a> <a href="#top">&uarr;</a></span></h4>
<dl class="rdoc-list note-list"><dt>path&lt;String&gt;
<dd>
<p>path of the file to be changed</p>
</dd><dt>module_name&lt;String|Class&gt;
<dd>
<p>the module to be manipulated</p>
</dd><dt>data&lt;String&gt;
<dd>
<p>the data to append to the class, can be also given as a block.</p>
</dd><dt>config&lt;Hash&gt;
<dd>
<p>give :verbose =&gt; false to not log the status.</p>
</dd></dl>

<h4 id="method-i-inject_into_module-label-Examples">Examples<span><a href="#method-i-inject_into_module-label-Examples">&para;</a> <a href="#top">&uarr;</a></span></h4>

<pre class="ruby"><span class="ruby-identifier">inject_into_module</span> <span class="ruby-string">&quot;app/helpers/application_helper.rb&quot;</span>, <span class="ruby-string">&quot;ApplicationHelper&quot;</span>, <span class="ruby-string">&quot;  def help; &#39;help&#39;; end\n&quot;</span>

<span class="ruby-identifier">inject_into_module</span> <span class="ruby-string">&quot;app/helpers/application_helper.rb&quot;</span>, <span class="ruby-string">&quot;ApplicationHelper&quot;</span> <span class="ruby-keyword">do</span>
  <span class="ruby-string">&quot;  def help; &#39;help&#39;; end\n&quot;</span>
<span class="ruby-keyword">end</span>
</pre>

                              <div class="method-source-code" id="inject_into_module-source">
            <pre><span class="ruby-comment"># File bundler/vendor/thor/lib/thor/actions/file_manipulation.rb, line 242</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">inject_into_module</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">module_name</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">config</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">pop</span> <span class="ruby-operator">:</span> {}
  <span class="ruby-identifier">config</span>[<span class="ruby-value">:after</span>] = <span class="ruby-regexp">/module #{module_name}\n|module #{module_name} .*\n/</span>
  <span class="ruby-identifier">insert_into_file</span>(<span class="ruby-identifier">path</span>, <span class="ruby-operator">*</span>(<span class="ruby-identifier">args</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">config</span>), <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-insert_into_file" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">insert_into_file</span><span
                                class="method-args">(destination, *args, &amp;block)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="insert_into_file-source">
            <pre><span class="ruby-comment"># File bundler/vendor/thor/lib/thor/actions/inject_into_file.rb, line 26</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">insert_into_file</span>(<span class="ruby-identifier">destination</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">data</span> = <span class="ruby-identifier">block_given?</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">block</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">shift</span>

  <span class="ruby-identifier">config</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">shift</span> <span class="ruby-operator">||</span> {}
  <span class="ruby-identifier">config</span>[<span class="ruby-value">:after</span>] = <span class="ruby-regexp">/\z/</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">config</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value">:before</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">config</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value">:after</span>)

  <span class="ruby-identifier">action</span> <span class="ruby-constant">InjectIntoFile</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword">self</span>, <span class="ruby-identifier">destination</span>, <span class="ruby-identifier">data</span>, <span class="ruby-identifier">config</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Actions.html#method-i-inject_into_file">inject_into_file</a>
                            </div>

                          </div>

                  <div id="method-i-inside" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">inside</span><span
                                class="method-args">(dir = &quot;&quot;, config = {}) { |destination_root| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Do something in the root or on a provided subfolder. If a relative path is given it’s referenced from the current root. The full path is yielded to the block you provide. The path is set back to the previous path when the method exits.</p>

<p>Returns the value yielded by the block.</p>

<h4 id="method-i-inside-label-Parameters">Parameters<span><a href="#method-i-inside-label-Parameters">&para;</a> <a href="#top">&uarr;</a></span></h4>
<dl class="rdoc-list note-list"><dt>dir&lt;String&gt;
<dd>
<p>the directory to move to.</p>
</dd><dt>config&lt;Hash&gt;
<dd>
<p>give :verbose =&gt; true to log and use padding.</p>
</dd></dl>

                              <div class="method-source-code" id="inside-source">
            <pre><span class="ruby-comment"># File bundler/vendor/thor/lib/thor/actions.rb, line 170</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">inside</span>(<span class="ruby-identifier">dir</span> = <span class="ruby-string">&quot;&quot;</span>, <span class="ruby-identifier">config</span> = {}, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">verbose</span> = <span class="ruby-identifier">config</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-value">:verbose</span>, <span class="ruby-keyword">false</span>)
  <span class="ruby-identifier">pretend</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:pretend</span>]

  <span class="ruby-identifier">say_status</span> <span class="ruby-value">:inside</span>, <span class="ruby-identifier">dir</span>, <span class="ruby-identifier">verbose</span>
  <span class="ruby-identifier">shell</span>.<span class="ruby-identifier">padding</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
  <span class="ruby-ivar">@destination_stack</span>.<span class="ruby-identifier">push</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">dir</span>, <span class="ruby-identifier">destination_root</span>)

  <span class="ruby-comment"># If the directory doesn&#39;t exist and we&#39;re not pretending</span>
  <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">destination_root</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">pretend</span>
    <span class="ruby-identifier">require</span> <span class="ruby-string">&quot;fileutils&quot;</span>
    <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir_p</span>(<span class="ruby-identifier">destination_root</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">result</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">pretend</span>
    <span class="ruby-comment"># In pretend mode, just yield down to the block</span>
    <span class="ruby-identifier">result</span> = <span class="ruby-identifier">block</span>.<span class="ruby-identifier">arity</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span> <span class="ruby-operator">?</span> <span class="ruby-keyword">yield</span>(<span class="ruby-identifier">destination_root</span>) <span class="ruby-operator">:</span> <span class="ruby-keyword">yield</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">require</span> <span class="ruby-string">&quot;fileutils&quot;</span>
    <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cd</span>(<span class="ruby-identifier">destination_root</span>) { <span class="ruby-identifier">result</span> = <span class="ruby-identifier">block</span>.<span class="ruby-identifier">arity</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span> <span class="ruby-operator">?</span> <span class="ruby-keyword">yield</span>(<span class="ruby-identifier">destination_root</span>) <span class="ruby-operator">:</span> <span class="ruby-keyword">yield</span> }
  <span class="ruby-keyword">end</span>

  <span class="ruby-ivar">@destination_stack</span>.<span class="ruby-identifier">pop</span>
  <span class="ruby-identifier">shell</span>.<span class="ruby-identifier">padding</span> <span class="ruby-operator">-=</span> <span class="ruby-value">1</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
  <span class="ruby-identifier">result</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-link_file" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">link_file</span><span
                                class="method-args">(source, *args)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Links the file from the relative source to the relative destination. If the destination is not given it’s assumed to be equal to the source.</p>

<h4 id="method-i-link_file-label-Parameters">Parameters<span><a href="#method-i-link_file-label-Parameters">&para;</a> <a href="#top">&uarr;</a></span></h4>
<dl class="rdoc-list note-list"><dt>source&lt;String&gt;
<dd>
<p>the relative path to the source root.</p>
</dd><dt>destination&lt;String&gt;
<dd>
<p>the relative path to the destination root.</p>
</dd><dt>config&lt;Hash&gt;
<dd>
<p>give :verbose =&gt; false to not log the status.</p>
</dd></dl>

<h4 id="method-i-link_file-label-Examples">Examples<span><a href="#method-i-link_file-label-Examples">&para;</a> <a href="#top">&uarr;</a></span></h4>

<pre class="ruby"><span class="ruby-identifier">link_file</span> <span class="ruby-string">&quot;README&quot;</span>, <span class="ruby-string">&quot;doc/README&quot;</span>

<span class="ruby-identifier">link_file</span> <span class="ruby-string">&quot;doc/README&quot;</span>
</pre>

                              <div class="method-source-code" id="link_file-source">
            <pre><span class="ruby-comment"># File bundler/vendor/thor/lib/thor/actions/file_manipulation.rb, line 51</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">link_file</span>(<span class="ruby-identifier">source</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
  <span class="ruby-identifier">config</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">pop</span> <span class="ruby-operator">:</span> {}
  <span class="ruby-identifier">destination</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">first</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">source</span>
  <span class="ruby-identifier">source</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">find_in_source_paths</span>(<span class="ruby-identifier">source</span>.<span class="ruby-identifier">to_s</span>))

  <span class="ruby-identifier">create_link</span> <span class="ruby-identifier">destination</span>, <span class="ruby-identifier">source</span>, <span class="ruby-identifier">config</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-prepend_file" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">prepend_file</span><span
                                class="method-args">(path, *args, &amp;block)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Actions.html#method-i-prepend_to_file">prepend_to_file</a>
                            </div>
                          </div>

                  <div id="method-i-prepend_to_file" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">prepend_to_file</span><span
                                class="method-args">(path, *args, &amp;block)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Prepend text to a file. Since it depends on <a href="Actions.html#method-i-insert_into_file"><code>insert_into_file</code></a>, it’s reversible.</p>

<h4 id="method-i-prepend_to_file-label-Parameters">Parameters<span><a href="#method-i-prepend_to_file-label-Parameters">&para;</a> <a href="#top">&uarr;</a></span></h4>
<dl class="rdoc-list note-list"><dt>path&lt;String&gt;
<dd>
<p>path of the file to be changed</p>
</dd><dt>data&lt;String&gt;
<dd>
<p>the data to prepend to the file, can be also given as a block.</p>
</dd><dt>config&lt;Hash&gt;
<dd>
<p>give :verbose =&gt; false to not log the status.</p>
</dd></dl>

<h4 id="method-i-prepend_to_file-label-Example">Example<span><a href="#method-i-prepend_to_file-label-Example">&para;</a> <a href="#top">&uarr;</a></span></h4>

<pre class="ruby"><span class="ruby-identifier">prepend_to_file</span> <span class="ruby-string">&#39;config/environments/test.rb&#39;</span>, <span class="ruby-string">&#39;config.gem &quot;rspec&quot;&#39;</span>

<span class="ruby-identifier">prepend_to_file</span> <span class="ruby-string">&#39;config/environments/test.rb&#39;</span> <span class="ruby-keyword">do</span>
  <span class="ruby-string">&#39;config.gem &quot;rspec&quot;&#39;</span>
<span class="ruby-keyword">end</span>
</pre>

                              <div class="method-source-code" id="prepend_to_file-source">
            <pre><span class="ruby-comment"># File bundler/vendor/thor/lib/thor/actions/file_manipulation.rb, line 173</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">prepend_to_file</span>(<span class="ruby-identifier">path</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">config</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">pop</span> <span class="ruby-operator">:</span> {}
  <span class="ruby-identifier">config</span>[<span class="ruby-value">:after</span>] = <span class="ruby-regexp">/\A/</span>
  <span class="ruby-identifier">insert_into_file</span>(<span class="ruby-identifier">path</span>, <span class="ruby-operator">*</span>(<span class="ruby-identifier">args</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">config</span>), <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Actions.html#method-i-prepend_file">prepend_file</a>
                            </div>

                          </div>

                  <div id="method-i-relative_to_original_destination_root" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">relative_to_original_destination_root</span><span
                                class="method-args">(path, remove_dot = true)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the given path relative to the absolute root (ie, root where the script started).</p>

                              <div class="method-source-code" id="relative_to_original_destination_root-source">
            <pre><span class="ruby-comment"># File bundler/vendor/thor/lib/thor/actions.rb, line 114</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">relative_to_original_destination_root</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">remove_dot</span> = <span class="ruby-keyword">true</span>)
  <span class="ruby-identifier">root</span> = <span class="ruby-ivar">@destination_stack</span>[<span class="ruby-value">0</span>]
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">path</span>.<span class="ruby-identifier">start_with?</span>(<span class="ruby-identifier">root</span>) <span class="ruby-operator">&amp;&amp;</span> [<span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">SEPARATOR</span>, <span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">ALT_SEPARATOR</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-string">&#39;&#39;</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">path</span>[<span class="ruby-identifier">root</span>.<span class="ruby-identifier">size</span><span class="ruby-operator">..</span><span class="ruby-identifier">root</span>.<span class="ruby-identifier">size</span>])
    <span class="ruby-identifier">path</span> = <span class="ruby-identifier">path</span>.<span class="ruby-identifier">dup</span>
    <span class="ruby-identifier">path</span>[<span class="ruby-value">0</span><span class="ruby-operator">...</span><span class="ruby-identifier">root</span>.<span class="ruby-identifier">size</span>] = <span class="ruby-string">&#39;.&#39;</span>
    <span class="ruby-identifier">remove_dot</span> <span class="ruby-operator">?</span> (<span class="ruby-identifier">path</span>[<span class="ruby-value">2</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>] <span class="ruby-operator">||</span> <span class="ruby-string">&quot;&quot;</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">path</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">path</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-remove_dir" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">remove_dir</span><span
                                class="method-args">(path, config = {})</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Actions.html#method-i-remove_file">remove_file</a>
                            </div>
                          </div>

                  <div id="method-i-remove_file" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">remove_file</span><span
                                class="method-args">(path, config = {})</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Removes a file at the given location.</p>

<h4 id="method-i-remove_file-label-Parameters">Parameters<span><a href="#method-i-remove_file-label-Parameters">&para;</a> <a href="#top">&uarr;</a></span></h4>
<dl class="rdoc-list note-list"><dt>path&lt;String&gt;
<dd>
<p>path of the file to be changed</p>
</dd><dt>config&lt;Hash&gt;
<dd>
<p>give :verbose =&gt; false to not log the status.</p>
</dd></dl>

<h4 id="method-i-remove_file-label-Example">Example<span><a href="#method-i-remove_file-label-Example">&para;</a> <a href="#top">&uarr;</a></span></h4>

<pre class="ruby"><span class="ruby-identifier">remove_file</span> <span class="ruby-string">&#39;README&#39;</span>
<span class="ruby-identifier">remove_file</span> <span class="ruby-string">&#39;app/controllers/application_controller.rb&#39;</span>
</pre>

                              <div class="method-source-code" id="remove_file-source">
            <pre><span class="ruby-comment"># File bundler/vendor/thor/lib/thor/actions/file_manipulation.rb, line 329</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">remove_file</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">config</span> = {})
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">behavior</span> <span class="ruby-operator">==</span> <span class="ruby-value">:invoke</span>
  <span class="ruby-identifier">path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">destination_root</span>)

  <span class="ruby-identifier">say_status</span> <span class="ruby-value">:remove</span>, <span class="ruby-identifier">relative_to_original_destination_root</span>(<span class="ruby-identifier">path</span>), <span class="ruby-identifier">config</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-value">:verbose</span>, <span class="ruby-keyword">true</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">options</span>[<span class="ruby-value">:pretend</span>] <span class="ruby-operator">&amp;&amp;</span> (<span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">path</span>) <span class="ruby-operator">||</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">symlink?</span>(<span class="ruby-identifier">path</span>))
    <span class="ruby-identifier">require</span> <span class="ruby-string">&quot;fileutils&quot;</span>
    <span class="ruby-operator">::</span><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rm_rf</span>(<span class="ruby-identifier">path</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Actions.html#method-i-remove_dir">remove_dir</a>
                            </div>

                          </div>

                  <div id="method-i-run" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">run</span><span
                                class="method-args">(command, config = {})</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Executes a command returning the contents of the command.</p>

<h4 id="method-i-run-label-Parameters">Parameters<span><a href="#method-i-run-label-Parameters">&para;</a> <a href="#top">&uarr;</a></span></h4>
<dl class="rdoc-list note-list"><dt>command&lt;String&gt;
<dd>
<p>the command to be executed.</p>
</dd><dt>config&lt;Hash&gt;
<dd>
<p>give :verbose =&gt; false to not log the status, :capture =&gt; true to hide to output. Specify :with to append an executable to command execution.</p>
</dd></dl>

<h4 id="method-i-run-label-Example">Example<span><a href="#method-i-run-label-Example">&para;</a> <a href="#top">&uarr;</a></span></h4>

<pre class="ruby"><span class="ruby-identifier">inside</span>(<span class="ruby-string">&#39;vendor&#39;</span>) <span class="ruby-keyword">do</span>
  <span class="ruby-identifier">run</span>(<span class="ruby-string">&#39;ln -s ~/edge rails&#39;</span>)
<span class="ruby-keyword">end</span>
</pre>

                              <div class="method-source-code" id="run-source">
            <pre><span class="ruby-comment"># File bundler/vendor/thor/lib/thor/actions.rb, line 249</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">run</span>(<span class="ruby-identifier">command</span>, <span class="ruby-identifier">config</span> = {})
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">behavior</span> <span class="ruby-operator">==</span> <span class="ruby-value">:invoke</span>

  <span class="ruby-identifier">destination</span> = <span class="ruby-identifier">relative_to_original_destination_root</span>(<span class="ruby-identifier">destination_root</span>, <span class="ruby-keyword">false</span>)
  <span class="ruby-identifier">desc</span> = <span class="ruby-node">&quot;#{command} from #{destination.inspect}&quot;</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">config</span>[<span class="ruby-value">:with</span>]
    <span class="ruby-identifier">desc</span> = <span class="ruby-node">&quot;#{File.basename(config[:with].to_s)} #{desc}&quot;</span>
    <span class="ruby-identifier">command</span> = <span class="ruby-node">&quot;#{config[:with]} #{command}&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">say_status</span> <span class="ruby-value">:run</span>, <span class="ruby-identifier">desc</span>, <span class="ruby-identifier">config</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-value">:verbose</span>, <span class="ruby-keyword">true</span>)

  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:pretend</span>]

  <span class="ruby-identifier">env_splat</span> = [<span class="ruby-identifier">config</span>[<span class="ruby-value">:env</span>]] <span class="ruby-keyword">if</span> <span class="ruby-identifier">config</span>[<span class="ruby-value">:env</span>]

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">config</span>[<span class="ruby-value">:capture</span>]
    <span class="ruby-identifier">require</span> <span class="ruby-string">&quot;open3&quot;</span>
    <span class="ruby-identifier">result</span>, <span class="ruby-identifier">status</span> = <span class="ruby-constant">Open3</span>.<span class="ruby-identifier">capture2e</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">env_splat</span>, <span class="ruby-identifier">command</span>.<span class="ruby-identifier">to_s</span>)
    <span class="ruby-identifier">success</span> = <span class="ruby-identifier">status</span>.<span class="ruby-identifier">success?</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">result</span> = <span class="ruby-identifier">system</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">env_splat</span>, <span class="ruby-identifier">command</span>.<span class="ruby-identifier">to_s</span>)
    <span class="ruby-identifier">success</span> = <span class="ruby-identifier">result</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">abort</span> <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">success</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">config</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-value">:abort_on_failure</span>, <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">exit_on_failure?</span>)

  <span class="ruby-identifier">result</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-run_ruby_script" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">run_ruby_script</span><span
                                class="method-args">(command, config = {})</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Executes a ruby script (taking into account WIN32 platform quirks).</p>

<h4 id="method-i-run_ruby_script-label-Parameters">Parameters<span><a href="#method-i-run_ruby_script-label-Parameters">&para;</a> <a href="#top">&uarr;</a></span></h4>
<dl class="rdoc-list note-list"><dt>command&lt;String&gt;
<dd>
<p>the command to be executed.</p>
</dd><dt>config&lt;Hash&gt;
<dd>
<p>give :verbose =&gt; false to not log the status.</p>
</dd></dl>

                              <div class="method-source-code" id="run_ruby_script-source">
            <pre><span class="ruby-comment"># File bundler/vendor/thor/lib/thor/actions.rb, line 286</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">run_ruby_script</span>(<span class="ruby-identifier">command</span>, <span class="ruby-identifier">config</span> = {})
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">behavior</span> <span class="ruby-operator">==</span> <span class="ruby-value">:invoke</span>
  <span class="ruby-identifier">run</span> <span class="ruby-identifier">command</span>, <span class="ruby-identifier">config</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-value">:with</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-constant">Bundler</span><span class="ruby-operator">::</span><span class="ruby-constant">Thor</span><span class="ruby-operator">::</span><span class="ruby-constant">Util</span>.<span class="ruby-identifier">ruby_command</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-source_paths" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">source_paths</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Holds source paths in instance so they can be manipulated.</p>

                              <div class="method-source-code" id="source_paths-source">
            <pre><span class="ruby-comment"># File bundler/vendor/thor/lib/thor/actions.rb, line 127</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">source_paths</span>
  <span class="ruby-ivar">@source_paths</span> <span class="ruby-operator">||=</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">source_paths_for_search</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-template" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">template</span><span
                                class="method-args">(source, *args) { |content| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Gets an ERB template at the relative source, executes it and makes a copy at the relative destination. If the destination is not given it’s assumed to be equal to the source removing .tt from the filename.</p>

<h4 id="method-i-template-label-Parameters">Parameters<span><a href="#method-i-template-label-Parameters">&para;</a> <a href="#top">&uarr;</a></span></h4>
<dl class="rdoc-list note-list"><dt>source&lt;String&gt;
<dd>
<p>the relative path to the source root.</p>
</dd><dt>destination&lt;String&gt;
<dd>
<p>the relative path to the destination root.</p>
</dd><dt>config&lt;Hash&gt;
<dd>
<p>give :verbose =&gt; false to not log the status.</p>
</dd></dl>

<h4 id="method-i-template-label-Examples">Examples<span><a href="#method-i-template-label-Examples">&para;</a> <a href="#top">&uarr;</a></span></h4>

<pre class="ruby"><span class="ruby-identifier">template</span> <span class="ruby-string">&quot;README&quot;</span>, <span class="ruby-string">&quot;doc/README&quot;</span>

<span class="ruby-identifier">template</span> <span class="ruby-string">&quot;doc/README&quot;</span>
</pre>

                              <div class="method-source-code" id="template-source">
            <pre><span class="ruby-comment"># File bundler/vendor/thor/lib/thor/actions/file_manipulation.rb, line 115</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">template</span>(<span class="ruby-identifier">source</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">config</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">pop</span> <span class="ruby-operator">:</span> {}
  <span class="ruby-identifier">destination</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">first</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">source</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">/#{TEMPLATE_EXTNAME}$/</span>, <span class="ruby-string">&quot;&quot;</span>)

  <span class="ruby-identifier">source</span>  = <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">find_in_source_paths</span>(<span class="ruby-identifier">source</span>.<span class="ruby-identifier">to_s</span>))
  <span class="ruby-identifier">context</span> = <span class="ruby-identifier">config</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value">:context</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">instance_eval</span>(<span class="ruby-string">&quot;binding&quot;</span>)

  <span class="ruby-identifier">create_file</span> <span class="ruby-identifier">destination</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">config</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">match</span> = <span class="ruby-constant">ERB</span>.<span class="ruby-identifier">version</span>.<span class="ruby-identifier">match</span>(<span class="ruby-regexp">/(\d+\.\d+\.\d+)/</span>)
    <span class="ruby-identifier">capturable_erb</span> = <span class="ruby-keyword">if</span> <span class="ruby-identifier">match</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">match</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">&gt;=</span> <span class="ruby-string">&quot;2.2.0&quot;</span> <span class="ruby-comment"># Ruby 2.6+</span>
      <span class="ruby-constant">CapturableERB</span>.<span class="ruby-identifier">new</span>(<span class="ruby-operator">::</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">binread</span>(<span class="ruby-identifier">source</span>), <span class="ruby-value">:trim_mode</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;-&quot;</span>, <span class="ruby-value">:eoutvar</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;@output_buffer&quot;</span>)
    <span class="ruby-keyword">else</span>
      <span class="ruby-constant">CapturableERB</span>.<span class="ruby-identifier">new</span>(<span class="ruby-operator">::</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">binread</span>(<span class="ruby-identifier">source</span>), <span class="ruby-keyword">nil</span>, <span class="ruby-string">&quot;-&quot;</span>, <span class="ruby-string">&quot;@output_buffer&quot;</span>)
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">content</span> = <span class="ruby-identifier">capturable_erb</span>.<span class="ruby-identifier">tap</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">erb</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">erb</span>.<span class="ruby-identifier">filename</span> = <span class="ruby-identifier">source</span>
    <span class="ruby-keyword">end</span>.<span class="ruby-identifier">result</span>(<span class="ruby-identifier">context</span>)
    <span class="ruby-identifier">content</span> = <span class="ruby-keyword">yield</span>(<span class="ruby-identifier">content</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">block</span>
    <span class="ruby-identifier">content</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-thor" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">thor</span><span
                                class="method-args">(command, *args)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Run a thor command. A hash of options can be given and it’s converted to switches.</p>

<h4 id="method-i-thor-label-Parameters">Parameters<span><a href="#method-i-thor-label-Parameters">&para;</a> <a href="#top">&uarr;</a></span></h4>
<dl class="rdoc-list note-list"><dt>command&lt;String&gt;
<dd>
<p>the command to be invoked</p>
</dd><dt>args&lt;Array&gt;
<dd>
<p>arguments to the command</p>
</dd><dt>config&lt;Hash&gt;
<dd>
<p>give :verbose =&gt; false to not log the status, :capture =&gt; true to hide to output. Other options are given as parameter to Bundler::Thor.</p>
</dd></dl>

<h4 id="method-i-thor-label-Examples">Examples<span><a href="#method-i-thor-label-Examples">&para;</a> <a href="#top">&uarr;</a></span></h4>

<pre class="ruby"><span class="ruby-identifier">thor</span> <span class="ruby-value">:install</span>, <span class="ruby-string">&quot;http://gist.github.com/103208&quot;</span>
<span class="ruby-comment">#=&gt; thor install http://gist.github.com/103208</span>

<span class="ruby-identifier">thor</span> <span class="ruby-value">:list</span>, <span class="ruby-value">:all</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">:substring</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&#39;rails&#39;</span>
<span class="ruby-comment">#=&gt; thor list --all --substring=rails</span>
</pre>

                              <div class="method-source-code" id="thor-source">
            <pre><span class="ruby-comment"># File bundler/vendor/thor/lib/thor/actions.rb, line 309</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">thor</span>(<span class="ruby-identifier">command</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
  <span class="ruby-identifier">config</span>  = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">pop</span> <span class="ruby-operator">:</span> {}
  <span class="ruby-identifier">verbose</span> = <span class="ruby-identifier">config</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value">:verbose</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">config</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value">:verbose</span>) <span class="ruby-operator">:</span> <span class="ruby-keyword">true</span>
  <span class="ruby-identifier">pretend</span> = <span class="ruby-identifier">config</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value">:pretend</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">config</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value">:pretend</span>) <span class="ruby-operator">:</span> <span class="ruby-keyword">false</span>
  <span class="ruby-identifier">capture</span> = <span class="ruby-identifier">config</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value">:capture</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">config</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value">:capture</span>) <span class="ruby-operator">:</span> <span class="ruby-keyword">false</span>

  <span class="ruby-identifier">args</span>.<span class="ruby-identifier">unshift</span>(<span class="ruby-identifier">command</span>)
  <span class="ruby-identifier">args</span>.<span class="ruby-identifier">push</span> <span class="ruby-constant">Bundler</span><span class="ruby-operator">::</span><span class="ruby-constant">Thor</span><span class="ruby-operator">::</span><span class="ruby-constant">Options</span>.<span class="ruby-identifier">to_switches</span>(<span class="ruby-identifier">config</span>)
  <span class="ruby-identifier">command</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot; &quot;</span>).<span class="ruby-identifier">strip</span>

  <span class="ruby-identifier">run</span> <span class="ruby-identifier">command</span>, <span class="ruby-value">:with</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-value">:thor</span>, <span class="ruby-value">:verbose</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">verbose</span>, <span class="ruby-value">:pretend</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">pretend</span>, <span class="ruby-value">:capture</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">capture</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-uncomment_lines" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">uncomment_lines</span><span
                                class="method-args">(path, flag, *args)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Uncomment all lines matching a given regex.  It will leave the space which existed before the comment hash in tact but will remove any spacing between the comment hash and the beginning of the line.</p>

<h4 id="method-i-uncomment_lines-label-Parameters">Parameters<span><a href="#method-i-uncomment_lines-label-Parameters">&para;</a> <a href="#top">&uarr;</a></span></h4>
<dl class="rdoc-list note-list"><dt>path&lt;String&gt;
<dd>
<p>path of the file to be changed</p>
</dd><dt>flag&lt;Regexp|String&gt;
<dd>
<p>the regexp or string used to decide which lines to uncomment</p>
</dd><dt>config&lt;Hash&gt;
<dd>
<p>give :verbose =&gt; false to not log the status.</p>
</dd></dl>

<h4 id="method-i-uncomment_lines-label-Example">Example<span><a href="#method-i-uncomment_lines-label-Example">&para;</a> <a href="#top">&uarr;</a></span></h4>

<pre class="ruby"><span class="ruby-identifier">uncomment_lines</span> <span class="ruby-string">&#39;config/initializers/session_store.rb&#39;</span>, <span class="ruby-regexp">/active_record/</span>
</pre>

                              <div class="method-source-code" id="uncomment_lines-source">
            <pre><span class="ruby-comment"># File bundler/vendor/thor/lib/thor/actions/file_manipulation.rb, line 293</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">uncomment_lines</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">flag</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
  <span class="ruby-identifier">flag</span> = <span class="ruby-identifier">flag</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:source</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">flag</span>.<span class="ruby-identifier">source</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">flag</span>

  <span class="ruby-identifier">gsub_file</span>(<span class="ruby-identifier">path</span>, <span class="ruby-regexp">/^(\s*)#[[:blank:]]*(.*#{flag})/</span>, <span class="ruby-string">&#39;\1\2&#39;</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="private-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Private Instance Methods</h3>
                </header>

                  <div id="method-i-capture" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">capture</span><span
                                class="method-args">(*args) { |*args| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="capture-source">
            <pre><span class="ruby-comment"># File bundler/vendor/thor/lib/thor/actions/file_manipulation.rb, line 350</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">capture</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
  <span class="ruby-identifier">with_output_buffer</span> { <span class="ruby-keyword">yield</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>) }
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-concat" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">concat</span><span
                                class="method-args">(string)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="concat-source">
            <pre><span class="ruby-comment"># File bundler/vendor/thor/lib/thor/actions/file_manipulation.rb, line 346</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">concat</span>(<span class="ruby-identifier">string</span>)
  <span class="ruby-ivar">@output_buffer</span>.<span class="ruby-identifier">concat</span>(<span class="ruby-identifier">string</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is a service of <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>, purveyors of fine <a href='https://jamesbritt.bandcamp.com/'>dance noise</a></p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

